package com.dlc.commonlibrary.utils;

import android.graphics.drawable.Drawable;
import android.support.v7.widget.DividerItemDecoration;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import com.dlc.commonlibrary.R;

/**
 * Created by John on 2017/7/19.
 */

public class RecyclerViewUtil {

    /**
     * 添加默认分割线
     * @param recyclerView
     * @param linearLayoutManager
     */
    public static void setDefaultDivider(RecyclerView recyclerView,
        LinearLayoutManager linearLayoutManager) {

        DividerItemDecoration decoration = new DividerItemDecoration(recyclerView.getContext(),
            linearLayoutManager.getOrientation());

        Drawable drawable =
            recyclerView.getResources().getDrawable(R.drawable.shape_defalut_divider);

        decoration.setDrawable(drawable);

        recyclerView.addItemDecoration(decoration);
    }
}
